#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;

using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;
using Agresso.Interface.Layer.Domain;
using Agresso.Interface.Layer.Service;

#endregion

namespace Agresso.Interface.Layer.Web
{
    public partial class DADeskPortForm : Form
    {
        DaDeskPort m_port;
        DADesk_PDA_Service m_daDeskService;
        UserControlDaDeskPortMapping m_parent;

        public DADeskPortForm(DaDeskPort company, UserControlDaDeskPortMapping parent)
        {
            InitializeComponent();
            Text = "Update Account";
            m_daDeskService = new DADesk_PDA_Service();
            m_parent = parent;
            m_port = company;
            textBoxPortCode.Text = m_port.PortCode;
            textBoxAgressoPort.Text = m_port.AgrPortCode;
        }

        private void button1OK_Click(object sender, EventArgs e)
        {
            updatePort();
            this.Close();
        }

        private void updatePort()
        {
            m_port.PortCode = textBoxPortCode.Text;
            m_port.AgrPortCode = textBoxAgressoPort.Text;
            m_daDeskService.UpdatePort(m_port);
            m_parent.UpdateSelectedItem(m_port);
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonApply_Click(object sender, EventArgs e)
        {
            updatePort();
            buttonApply.Enabled = false;
        }

        private void DADeskVesselForm_Load(object sender, EventArgs e)
        {
            textBoxAgressoPort.Focus();
        }

        private void activate_apply(object sender, KeyPressEventArgs e)
        {
            buttonApply.Enabled = true;
        }
    }
}